﻿using GraphProcessor;
using IQIGame.Onigao.Logic;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(LevelEditorConst.Execution + "/" + LevelEditorConst.ChangeLevelParams, typeof(LevelServiceGraph))]
    public class LevelServiceExecutionNode_ChangeLevelParams : LevelServiceExecutionNode
    {
        protected override ServiceExecutionType mServiceType => ServiceExecutionType.ChangeLevelParams;

        public override string name => LevelEditorConst.ChangeLevelParams;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.ChangeLevelParams, "LevelParam表ID(可写参数)")]
        public int key;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.ChangeLevelParams, "修改类型")]
        public int type;
        public int value;

        protected override LevelServiceCustomConfig CreateConfig()
        {
            return new LevelServiceExecutionCustom_ChangeLevelParams()
            {
                type = this.type,
                key = this.key,
                value = this.value
            };
        }
        
        protected override void OnSync(EditorLevelServiceExecutionConfig newConfig, LevelServiceExecutionNode tempNode)
        {
            if (tempNode is LevelServiceExecutionNode_ChangeLevelParams rNode)
            {
                this.type = rNode.type;
                this.key = rNode.key;
                this.value = rNode.value;
            }
        }
    }
}